package com.bike.controller.api;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bike.controller.BaseController;
import com.bike.entity.HhBusiness;
import com.bike.entity.HhBusinessRecord;
import com.bike.entity.HhBusinessUser;
import com.bike.entity.HhPayRecord;
import com.bike.service.impl.HhAgentServiceImpl;
import com.bike.service.impl.HhBusinessRecordServiceImpl;
import com.bike.service.impl.HhBusinessServiceImpl;
import com.bike.service.impl.HhBusinessUserServiceImpl;
import com.bike.service.impl.HhOrderServiceImpl;
import com.bike.service.impl.HhPayRecordServiceImpl;
import com.bike.util.Constant;
import com.bike.util.PageData;

 
@Controller
@RequestMapping(value="/apiBusinessRecord")
public class HhApiBusinessRecordController extends BaseController {
	
		@Autowired
		private HhAgentServiceImpl  hhAgentService;
		@Autowired
		private HhOrderServiceImpl  orderServiceImpl;
		@Autowired
		private HhBusinessUserServiceImpl  businessUserServiceImpl;
		@Autowired
		private HhBusinessServiceImpl  businessServiceImpl;
		@Autowired
		private HhPayRecordServiceImpl  hhPayRecordServiceImpl;
		@Autowired
		private HhBusinessRecordServiceImpl  hhRecordServiceImpl;
		/**
		 * 列表查询(或根据条件)员工 收费明细
		 */
		@RequestMapping("employList")
		@ResponseBody
		public PageData employList(HttpServletRequest request,Model model){
			PageData pd=PageData.getToPageData(request);
			PageData result=getSuccessPd();
			HhBusinessUser businessUser=(HhBusinessUser) request.getAttribute("businessUser");
			if(businessUser.getRole().equals(Constant.employ)){
				
				pd.put("businessUserId", businessUser.getBusinessUserId());
				List<HhPayRecord> HhPayRecord= hhPayRecordServiceImpl.listAll(pd);
				result.put("rows", HhPayRecord);
			}
			return result;
		}
		/**
		 * 列表查询(或根据条件)  老板收费明细
		 */
		@RequestMapping("list")
		@ResponseBody
		public PageData list(HttpServletRequest request,Model model){
			PageData pd=PageData.getToPageData(request);
			PageData result=getSuccessPd();
			HhBusinessUser businessUser=(HhBusinessUser) request.getAttribute("businessUser");
			pd.put("businessId", businessUser.getBusinessId());
			List<HhBusinessRecord> businessRecords= hhRecordServiceImpl.listAll(pd);
			result.put("rows", businessRecords);
			return result;
		}
		 
		
		
		
		
}
